package org.su.webadapter.bind;


import org.su.generalmvc.IEditor;
import org.su.webadapter.MultipartHttpServletRequest;

import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import java.lang.reflect.Method;

public class FormFileEditor implements IEditor {

	@Override
	public Object getParamValue(String paramName, Class<?> paramType, int paramIndex, Method writer, ServletRequest request,
								ServletResponse response) {
		Object result = null;
		try {
			MultipartHttpServletRequest mRequest = (MultipartHttpServletRequest)request;
			result = mRequest.getFormFile(paramName);
		} catch (NumberFormatException ex) {
			throw new ParamBindException(ex, paramName);
		}
		return result;
	}
	

}
